//
//  LoadingView.m
//  Picture_book
//
//  Created by rimi on 15/10/22.
//  Copyright (c) 2015年 LIYaoshan. All rights reserved.
//

#import "LoadingView.h"

@implementation LoadingView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initializeAppearance];
    }
    return self;
}

- (void)initializeAppearance {
    self.frame = [UIScreen mainScreen].bounds;
    self.center = flexibleCenter(CGPointMake(160, 284));
    self.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.500];
    
    NSMutableArray * imageNameArray = [NSMutableArray array];

    for (int i = 1; i <= 2; i ++) {
        NSString * imageName = [NSString stringWithFormat:@"load%d.png",i];
        UIImage * image = [UIImage imageNamed:imageName];
        [imageNameArray addObject:image];
    }
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:flexibleFrame(CGRectMake(0, 0, 170, 120), NO)];
    imageView.center = self.center;
    imageView.contentMode = UIViewContentModeScaleAspectFit;  // 视图等比例缩放
    [imageView setAnimationImages:imageNameArray];
    imageView.animationDuration = 0.3;
    imageView.animationRepeatCount = 0;
    [imageView startAnimating];
    
    [self addSubview:imageView];
    
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
    label.center = flexibleCenter(CGPointMake(160, 235));
    label.text = @"努力加载中...";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
    [self addSubview:label];
    
}

@end
